package com.ruoyi.jiuzai.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jiuzai.domain.Wuzileibie;
import com.ruoyi.jiuzai.service.IWuzileibieService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物资类别Controller
 * 
 * @author ruoyi
 * @date 2025-06-19
 */
@RestController
@RequestMapping("/jiuzai/wuzileibie")
public class WuzileibieController extends BaseController
{
    @Autowired
    private IWuzileibieService wuzileibieService;

    /**
     * 查询物资类别列表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzileibie:list')")
    @GetMapping("/list")
    public TableDataInfo list(Wuzileibie wuzileibie)
    {
        startPage();
        List<Wuzileibie> list = wuzileibieService.selectWuzileibieList(wuzileibie);
        return getDataTable(list);
    }

    /**
     * 导出物资类别列表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzileibie:export')")
    @Log(title = "物资类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Wuzileibie wuzileibie)
    {
        List<Wuzileibie> list = wuzileibieService.selectWuzileibieList(wuzileibie);
        ExcelUtil<Wuzileibie> util = new ExcelUtil<Wuzileibie>(Wuzileibie.class);
        util.exportExcel(response, list, "物资类别数据");
    }

    /**
     * 获取物资类别详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzileibie:query')")
    @GetMapping(value = "/{leiId}")
    public AjaxResult getInfo(@PathVariable("leiId") Long leiId)
    {
        return success(wuzileibieService.selectWuzileibieByLeiId(leiId));
    }

    /**
     * 新增物资类别
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzileibie:add')")
    @Log(title = "物资类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Wuzileibie wuzileibie)
    {
        return toAjax(wuzileibieService.insertWuzileibie(wuzileibie));
    }

    /**
     * 修改物资类别
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzileibie:edit')")
    @Log(title = "物资类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Wuzileibie wuzileibie)
    {
        return toAjax(wuzileibieService.updateWuzileibie(wuzileibie));
    }

    /**
     * 删除物资类别
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzileibie:remove')")
    @Log(title = "物资类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{leiIds}")
    public AjaxResult remove(@PathVariable Long[] leiIds)
    {
        return toAjax(wuzileibieService.deleteWuzileibieByLeiIds(leiIds));
    }


}

